package com.wanyang.controller;

import com.wanyang.service.GoldShopService;
import com.wanyang.vo.ApiResult;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("goldShop")
public class GoldShopController {

    @Autowired
    private GoldShopService goldShopService;

    @PostMapping("exchange")
    public ApiResult exchange(@RequestBody ExchangeDTO exchangeDTO) {
        goldShopService.exchange(exchangeDTO.goodsId, exchangeDTO.quantity);
        return ApiResult.success();
    }

    @Data
    public static class ExchangeDTO {
        private Integer goodsId;
        private Integer quantity;
    }

}
